<?php
$this->menu=array(
	array('label'=>'List packing_list_packages_cargo', 'url'=>array('index')),
	array('label'=>'Manage packing_list_packages_cargo', 'url'=>array('admin')),
);
?>

<h1>Cargo still in warehouse</h1>
<?php 
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'grid_ListCargo',
	'dataProvider'=>cargo::model()->in_warehouse(),
	'columns'=>array(
		'in_date:date',
		array(
			'name'=>'marking',
			'value'=>'$data->do_ref->ref_no',
			'type'=>'text',
		),
		array(
			//'value'=>'($data->getLeftOver("qty") == 0)?null:$data->getLeftOver("qty")',
			'name'=>'consignee.cname',
		),
		array(
			'value'=>'($data->getLeftOver("qty") == 0)?null:$data->getLeftOver("qty")',
			'name'=>'Quantity',
		),
		array(
			'value'=>'($data->getLeftOver("wt") ==0)?null:$data->getLeftOver("wt")',
			'name'=>'Weight',
		),
		array(
			'value'=>'($data->getLeftOver("m3") == 0)?null:$data->getLeftOver("m3")',
			'name'=>'M3',
		),
		array(
			'class'=>'CLinkColumn',
			'label'=>'Add',
			'urlExpression'=>'CHtml::normalizeUrl(array("packing_list_packages_cargo/create","cargo_id"=>$data->id,"packing_id"=>"'.$model['packing_list']->id.'","pid"=>"'.$model['package_cargo']->package_id.'"))',
			'linkHtmlOptions'=>array('id'=>'grid_addPackageCargo'),
		),
	),
));
?>
<?php 
$cs = Yii::app()->getClientScript();
$packageUrl = CHtml::normalizeUrl(array('packing_list_packages/view'));
$script =<<<EOD
$.packing_list_packages_cargo={
				afterSubmit:function(data){
					if(data.id != '')
						window.location = "$packageUrl?id="+data.id; 
				}
			};
$('a#grid_addPackageCargo').live('click',function(){
	var dialogButton = {
		Add:function(){
			$.packing_list_packages_cargo=$.packing_list_packages_cargo;
			$(this).find('form').find('[type=submit]').click();
		}
	};
	$.simplelogdialog({url:$(this).attr('href')},{width:500},dialogButton);
	return false;
});
EOD;
$cs->registerScript('packing_list_packages_cargo#view',$script,CClientScript::POS_END);
?>